<template name="elements_compileContract">
    <div class="row clear compile-contract">
        {{#if onlyByteCode}}                    
            {{#if TemplateVar.get "show"}}
                {{TemplateVar.set "byteTextareaShown" true}}
                    <div class="col col-8 mobile-full replay-protection-div">
                    
                        <button class="hide-data dapp-block-button dapp-small">{{i18n 'wallet.send.showLessOptions'}}</button>

                        <h3>{{i18n 'wallet.send.data'}}</h3>
                    </div>  

            {{else}}
                <div class="col col-12 mobile-full">
                    {{TemplateVar.set "byteTextareaShown" false}}
                    <button class="show-data dapp-block-button dapp-small">{{i18n 'wallet.send.showMoreOptions'}}</button>
                </div>
            {{/if}}
        {{/if}}


        <div class="col col-8 mobile-full {{#if $eq (TemplateVar.get 'selectedType') 'source-code'}}source-code{{/if}}">

            {{reactiveContext}}


            {{#unless onlyByteCode}}
                <div class="dapp-segmented-control dapp-small">
                    <input type="radio" value="source-code" id="source-code" name="contract-type" checked>
                    <label for="source-code"> {{i18n 'wallet.contracts.contractSourceCode'}}</label>

                    <input type="radio" value="byte-code" id="byte-code" name="contract-type">
                    <label for="byte-code"> {{i18n 'wallet.contracts.contractByteCode'}} </label>
                </div>
            {{/unless}}

            
            <textarea id="contract-source-editor" cols="20" rows="20"></textarea>
            {{#if TemplateVar.get "show"}}
                {{> dapp_dataTextarea cols="20" rows="8" value=(TemplateVar.get "txData")}}
            {{/if}}
        </div>
        
        <div class="col col-4 mobile-full send-info">
            <br>
            
            {{#if $eq (TemplateVar.get "selectedType") "source-code"}}

                {{#if TemplateVar.get "compiling"}}
                    {{> spinner}}

                {{else}}
                    {{#with TemplateVar.get "compileError"}}
                        <p class="orange">
                            <i class="icon-shield"></i> {{i18n 'wallet.contracts.error.compile'}}
                            <br><br>
                            <pre>{{this}}</pre>
                        </p>

                    {{else}}
                        {{#with TemplateVar.get "compiledContracts"}}
                            <h3>{{i18n 'wallet.contracts.selectContract'}}</h3>
                            <select class="compiled-contracts">
                                <option disabled selected>{{i18n "wallet.contracts.pickContract"}}</option>
                                {{#each this}}
                                    <option value="{{name}}" selected="{{selected}}">{{toSentence name true}}</option>
                                {{/each}}    
                            </select>
                        {{else}}
                            {{{i18n "wallet.contracts.noContract"}}}
                        {{/with}}
                        
                        {{#with selectedContractInputs}}
                            <h3>{{i18n 'wallet.contracts.constructorParameters'}}</h3>
                            {{#each selectedContractInputs}}
                                {{> Template.dynamic template=template}}
                            {{/each}}
                        {{/with}}
                    {{/with}}
                {{/if}}

            {{else}}

                {{#if TemplateVar.get "show"}}

                    {{#if onlyByteCode}}
                        {{{i18n 'wallet.send.texts.addData'}}}
                    {{/if}}

                    {{#if codeNotExecutable}}
                        <p class="orange">
                            <i class="icon-shield"></i> {{i18n 'wallet.send.texts.dataNotExecutable'}}
                        </p>
                    {{/if}}
                {{/if}}
            {{/if}}
        </div>

        <div class="dapp-clear-fix"></div>
    </div>
</template>
